<?php

/*
 * 
 *  archivo de carga de configuracion y componentes
 * 
 */

session_start();

define("PATH_ROOT",  getcwd());

//inlcuyendo los controles

$modules = array('active_record','base'.DIRECTORY_SEPARATOR.'_base_controller','model','controller');

foreach ($modules as $llave=>$mod){
    
    $files_mod = array_diff(scandir(PATH_ROOT.DIRECTORY_SEPARATOR.$mod), array(".","..","index.php"));
    
    foreach ($files_mod as $llave_file=>$mod_file){
        
        $info_path = pathinfo(PATH_ROOT.DIRECTORY_SEPARATOR.$mod.DIRECTORY_SEPARATOR.$mod_file);

        if ($info_path['extension'] == "php"){
            include PATH_ROOT.DIRECTORY_SEPARATOR.$mod.DIRECTORY_SEPARATOR.$mod_file;       
        }  
    }    
    
}

//  incluyendo la configuracion del sistema ..

if (file_exists(PATH_ROOT.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."main.php")){
    include (PATH_ROOT.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."main.php");
}
else{
    die("No se encontro el archivo de configuracion del sistema");
}

if (!isset($config)){
    die("No se encontro la configuracion del sistema");
}

//cargando la configuracion de la conexion a base de datos

ActiveRecord::$_type = $config['active_record']['dbtype'];
ActiveRecord::$_host = $config['active_record']['host'];
ActiveRecord::$_user = $config['active_record']['user'];
ActiveRecord::$_pass =$config['active_record']['passwd'];
ActiveRecord::$_dbname = $config['active_record']['dbname'];




?>
